package com.zhim.controller.demo;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Zyang on 2018/2/26.
 */
@Controller
@RequestMapping("/demo/Demo")
public class DemoController {

    @RequestMapping("/index")
    public String index(Model model) {
        return "demo/index";
    }

    @RequestMapping("/helloworld")
    public String hello(Model model) {
        model.addAttribute("greeting", "Hello Spring MVC");
        return "demo/helloworld";
    }

    /**
     * 跳转
     * @return
     */
    @RequestMapping(value = "/redirect", method = RequestMethod.GET)
    public String redirect() {

        return "redirect:finalPage";
    }

    @ResponseBody
    @RequestMapping(value = "/finalPage", method = RequestMethod.GET)
    public String finalPage() {
        return "final";
    }
}
